<!DOCTYPE html>
<html lang="en">
<head>
  <meta charset="UTF-8">
  <meta http-equiv="X-UA-Compatible" content="IE=edge">
  <meta name="viewport" content="width=device-width, initial-scale=1.0">
  <title>Document</title>
  <style>
    #outter {
      width: 200px;
      height: 200px;
      background-color: skyblue;
      position: relative;
    }
    #inner {
      position: absolute;
      top: 50px;
      left: 50px;
      width: 100px;
      height: 100px;
      background-color: pink;
    }
  </style>
</head>
<body>
  <div id="outter">
    <div id="inner"></div>
    </div>

  <script>
    // 事件冒泡的流程

    // 基于DOM树形结构
    // 事件在目标元素上处理后, 会由内向外(上)逐层传递
    // 应用场景: 事件代理/委托/委派
    let outter = document.querySelector('#outter')
    let inner = document.querySelector('#inner')

    outter.addEventListener('click', function(){
      console.log('捕获 outter');
    }, true)

    inner.addEventListener('click', function(){
      console.log('捕获 inner');
    }, true)

    outter.addEventListener('click', function(){
      console.log('冒泡 outter');
    })

    inner.addEventListener('click', function(){
      console.log('冒泡 inner');
    })
  </script>
</body>
</html>